FROM python:3.11-slim

ENV LANG=C.UTF-8

ARG ARCH="cpu"

ARG PKGNAME

RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \
    build-essential \
    default-jre \
    libgl1-mesa-glx \
    libjemalloc-dev \
    ffmpeg \
    espeak


COPY . /home/llm

RUN pip install --no-cache-dir --upgrade pip setuptools && \
    if [ ${ARCH} = "cpu" ]; then pip install --pre --upgrade ipex-llm[all] --extra-index-url https://download.pytorch.org/whl/cpu; fi && \
    pip install  --no-cache-dir "tiktoken>=0.7.0" transformers==4.44 "trl<0.12.0" && \
    pip install  --no-cache-dir "datasets==2.16.1" soundfile && \
    pip install  --no-cache-dir -r /home/llm/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home/llm

WORKDIR /home/llm
ENTRYPOINT ["python", "service.py"]
